package com.example.a2209_shop.adapter

import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.a2209_shop.R
import com.example.base.entity.GoodsEntity

class GoodsMutliAdapter:BaseMultiItemQuickAdapter<GoodsEntity,BaseViewHolder>() {
    init {
        addItemType(0, R.layout.item_goods)
        addItemType(1, R.layout.item_goods)
    }

    override fun convert(holder: BaseViewHolder, item: GoodsEntity) {
        when (holder.itemViewType){
            0->{
                Glide.with(context).load(item.goods_default_icon).into(holder.getView(R.id.goods_icon))
                holder.setText(R.id.goods_desc,item.goods_desc)
                holder.setText(R.id.goods_price,"￥${item.goods_default_price}.00起")
            }
            1->{
                Glide.with(context).load(item.goods_default_icon).circleCrop().into(holder.getView(R.id.goods_icon))
                holder.setText(R.id.goods_desc,item.goods_desc)
                holder.setText(R.id.goods_price,"￥${item.goods_default_price}")
            }
        }
    }
}